<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>User managerment</title>
<link href="css/site.css" rel="stylesheet" type="text/css" />
<link href="css/user.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" name="form1" method="post" action="">
  <p><img src="images/login.png"  alt="Login" /></p>
  <hr />
  
  <table width="400" border="0">
    <tr>
      <th scope="col">Tên tài khoản</th>
      <td scope="col"><input type="text" name="username" id="username" required="required" /></td>
    </tr>
    <tr>
       <th scope="col">Mật khẩu</th>
      <td><input type="password" name="pwd" id="pwd" required="required" /></td>
    </tr>
    <tr>
      <th colspan="2" style="padding-top:10px"><input name="btnDangNhap" type="submit" class="button1" id="btnDangNhap" value="Đăng nhập" /> &nbsp;&nbsp;&nbsp;&nbsp;
        <input name="btnCancle" type="reset" class="button1" id="btnCancle" value="Hủy bỏ" />

           <?php 
				include_once("config/database.php");
				$db =  new database();
				if(isset($_POST["pwd"]) and isset($_POST["btnDangNhap"]))
				{										
					$pwd = md5(mysql_real_escape_string($_POST["pwd"]));
					$username = mysql_real_escape_string($_POST["username"]);
					if(!$db->isExist("user","username='".$username."' and password='".$pwd."'"))
					{
						echo "<h3 class='error1'>** Đăng nhập thất bại: Tài khoản đặng nhập không đúng</h3>";
						echo "<p>$pwd</p>";
					}
					else
					{
						setcookie("username", $username,time() + 3600);
						include_once("config/util.php");
						showMessage("Đăng nhập thành công!");
						goToPage("index.php");
					}		
				}
		?>
     
        
      </th>
    </tr>
  </table>
    <hr />
</form>


    
    
</body>
</html>
